﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kokomo.PeInspector.Reflection.Disassembly
{
	/// <summary>
	/// Represents the definition of a code metric.
	/// </summary>
	public class CodeMetricDefinition
	{
		static CodeMetricDefinition()
		{
			BranchCount = new CodeMetricDefinition("Number of branches", "Coding");
			LinesOfCode = new CodeMetricDefinition("Lines of code", "Coding");
			MethodLength = new CodeMetricDefinition("Method length", "MSIL");
		}

		/// <summary>
		/// Gets the <see cref="CodeMetricDefinition"/> of <c><Lines of Code/c> metric.
		/// </summary>
		public static CodeMetricDefinition LinesOfCode { get; private set; }
		/// <summary>
		/// Gets the <see cref="CodeMetricDefinition"/> of <c>Method Length</c> metric.
		/// </summary>
		public static CodeMetricDefinition MethodLength { get; private set; }
		/// <summary>
		/// Gets the <see cref="CodeMetricDefinition"/> of <c>Branch Count</c> metric.
		/// </summary>
		public static CodeMetricDefinition BranchCount { get; private set; }

		/// <summary>
		/// Gets the label of the metric.
		/// </summary>
		public string Label { get; private set; }
		/// <summary>
		/// Gets the category of the metric.
		/// </summary>
		public string Category { get; private set; }

		/// <summary>
		/// Initializes a new instance of <see cref="CodeMetricDefinition"/>.
		/// </summary>
		/// <param name="label">The label of the metric.</param>
		/// <param name="category">The category of the metric.</param>
		/// <exception cref="ArgumentNullException"><paramref name="label"/> is <c>null</c>.</exception>
		/// <exception cref="ArgumentNullException"><paramref name="category"/> is <c>null</c>.</exception>
		public CodeMetricDefinition(
			string label,
			string category
			)
		{
			if (label == null) throw new ArgumentNullException("label");
			if (category == null) throw new ArgumentNullException("category");

			this.Label = label;
			this.Category = category;
		}

		public override string ToString()
		{
			return string.Format("{0}:{1}", this.Category, this.Label);
		}
	}
}
